/*
 * @Author: zhouxiaofan
 * @Date: 2021-11-20 21:18:02
 * @LastEditTime: 2021-11-20 22:11:19
 * @LastEditors: Please set LastEditors
 * @Description: 用户评论
 * @FilePath: /blogServe/src/service/comment.service.js
 */
const connection = require('../app/database');

class CommentService {
  async create(momentId, content, userId) {
    const statement = `INSERT INTO comment (content, moment_id, user_id) VALUES(?, ? ,?);`;
    const [result] = await connection.execute(statement, [content, momentId, userId]);
    return result;
  }

  async reply(momentId, content, userId, commentId) {
    console.log("1");
    const statement = `INSERT INTO comment (content, moment_id, user_id, comment_id) VALUES(?, ? ,?, ?);`
    console.log("2");
    const [result] = await connection.execute(statement, [content, momentId, userId, commentId]);
    return result;
  }
}

module.exports = new CommentService();